import React from 'react';
import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom';
import { Layout } from 'antd';
import Login from './pages/Login';
import FundList from './pages/FundList';
import FundDetail from './pages/FundDetail';
import MyFunds from './pages/MyFunds';
import Navbar from './components/Navbar';
import './App.css';

const { Content } = Layout;

function App() {
  const isAuthenticated = localStorage.getItem('token');

  return (
    <Router>
      <Layout className="layout">
        <Navbar />
        <Content style={{ padding: '0 50px', marginTop: 64 }}>
          <div className="site-layout-content">
            <Routes>
              <Route path="/login" element={<Login />} />
              <Route
                path="/funds"
                element={isAuthenticated ? <FundList /> : <Navigate to="/login" />}
              />
              <Route
                path="/fund/:code"
                element={isAuthenticated ? <FundDetail /> : <Navigate to="/login" />}
              />
              <Route
                path="/my-funds"
                element={isAuthenticated ? <MyFunds /> : <Navigate to="/login" />}
              />
              <Route path="/" element={<Navigate to="/funds" />} />
            </Routes>
          </div>
        </Content>
      </Layout>
    </Router>
  );
}

export default App; 